{extend name="public:base" /}

{block name="main-content"}

<div class="page-content">
    <div class="row">
        <div class="col-xs-9 col-sm-9 col-md-9  col-lg-9">
            <h5>为<span style="color: #0f0;">{$role.name}</span>设置权限</h5>
        </div>
    </div>
    <div class="row">
        <form method="post"  class="accessRoleForm"  action="{:url('admin/role/access', 'role_id='.$role.id)}">
            <div class="role_access_set_wrap" role="form">
                <div class="form-group">
                    <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                        {notempty name="accessList"}
                        {foreach name="accessList" id="vo"}
                        <div class="checkbox">
                            <label>
                                <input type="checkbox" name="access_ids[]" value="{$vo.id}"
                                       {if condition="in_array( $vo.id, $roleAccessIds )"} checked {/if}
                                >
                                {$vo.title}
                            </label>
                        </div>
                        {/foreach}
                        {/notempty}
                    </div>
                </div>
                <div class="col-xs-12">
                    <input type="hidden" name="role_id" value="{$role.id}">
                    <button type="submit" class="btn btn-primary pull-left  save">确定</button>
                </div>
            </div>
        </form>
    </div><!-- /.row -->
</div><!-- /.page-content -->

{/block}
{block name="scripts"}
<script type="text/javascript">
    /* 编辑角色 */
    $(function () {

        $('.accessRoleForm').ajaxForm({
            success: accessRoleForm, // 这是提交后的方法
            dataType: 'json'
        });
    });

    //编辑角色
    function accessRoleForm(data) {
        if (data.code == 1) {
            $(':input', '.roleForm')
                    .not(':button, :submit, :reset, :hidden')
                    .val('')
                    .removeAttr('checked')
                    .removeAttr('selected');
            layer.msg(data.msg, {icon: 6});
            if (data.url) {
                window.location.href = data.url;
            }
        } else {
            layer.msg(data.msg, {icon: 5});
        }
    }

</script>
{/block}